<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>登录系统</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta name="Description" content=""/>
<meta name="Keywords" content=""/>
<meta name="Copyright" content=""/>
<meta http-equiv="pragma" content="no-cache"/>
<link rel="icon" href="/Public/Home/favicon.ico" type="image/x-icon"/>
<script src='/Public/js/jquery-1.7.2.min.js'></script>
<script src='/Public/js/layer/layer.js'></script>
<link rel="stylesheet" type="text/css" href="/Public/Home/style/member/css/start30.css"/>
</head>
<body>
<div id="login" >
	<div id="container">
		<div class="form_wrap" id="form">
			<div class="lf_head">
				<div class="translate">忘记密码</div>
			</div>
			<form>
				 <div class="lf_line">
					<label for="uname" class="translate">邮箱</label>
					 <input type="text" id="txtemail" name="email" value="" class="input_text" style="width:35%;display:inline;float:left" >&nbsp;
					<input type="button" value="发送" onclick="time(this);" class="btn btn-primary pemailcheck" id="jhwjjc2" name="jhwjjc" style="width:17%;height:22px; padding-left: 6px;border-radius: 15px;font-size:12px; border: 1px solid #f8f9fae3;color: #ffffff;background: #ff8c00;;float:left" onclick="settime(this)">
				 </div>
            <div class="lf_line">
					<label for="upass" class="translate">验证码</label>
					<input type="text" id="email_code" name="email_code" value="" class="input_text">
					<br>
				</div>
				<div class="lf_line">
					<label for="upass" class="translate">新密码</label>
					<input type="password" id="password" name="password" value="" class="input_text">
					<br>
				</div>
				<div class="lf_line">
					<label for="upass" class="translate">确认新密码</label>
					<input type="password" id="repassword" name="repassword" value="" class="input_text">
					<br>
				</div>
				<div class="lf_line" style='    text-align: center;'>
				  <input class="button_orange translate" type='button' onclick='forget()' title="FORGET" value='找回密码'>
				</div>
			<form>
			<div class="lf_line">
				<p class="lf_line_italic">
					<a href="{:U('Login/index')}" id="recover" class="translate">登录</a>
					<span class="translate"></span></p>
			</div>
		</div>
	</div>
</div>
<script>
function forget() {
    if ($("#txtemail").val() == "") {
        layer.msg("请填写邮箱");
        return false;
    } else if ($("#email_code").val() == "") {
        layer.msg("请填写邮箱验证码");
        return false;
    }
    else if ($("#password").val() == "") {
        layer.msg("请填写密码");
        return false;
    }
    else if ($("#password").val() != $("#repassword").val()) {
        layer.msg("两次密码不一致");
        return false;
    }
    
    if (!isEmail($("#txtemail").val())) {
        layer.msg("邮箱格式不正确");
        return false;
    }
    $.post("{:U('Reg/forgotcl')}", $("form").serialize(), function(data) { 
        if (data.status==1) {
        	layer.msg(data.info);
        	location.href= "{:U('Login/index')}";    
        } else { 
            alert(data.info);
        }},'json');
}

var wait = 60;

function time(o) {       
    if ($("#txtemail").val() == "") {
        layer.msg("请填写邮箱");
        return false;
    }       

    if (!isEmail($("#txtemail").val())) {
        layer.msg("邮箱格式不正确");
        return false;
    }
     if (wait == 60) {  
    	 sendEmail();
    }
    if (wait == 0) {
        o.removeAttribute("disabled");  
        o.value="Send out";
        wait = 60;  
    }else{
    	o.setAttribute("disabled", true);  
        o.value="again(" + wait + ")";  
        wait--;  
        setTimeout(function() {  
        	time(o)  
        },1000)
    }
}
function isEmail(str) {
    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
    return reg.test(str);
}

function sendEmail(){
	$.post("{:U('Reg/sendEmail')}", { email: $("#txtemail").val(),type:2 }, function(msg) { 
    	layer.msg(msg.info); 
    	});
} 
</script>
</body>
</html>
